﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.Business;
using University.Workshop.Model;

namespace University.Workshop.WinApp
{
    public partial class NewAppointment : Form
    {
        public NewAppointment()
        {
            InitializeComponent();
            IssuePermits();
        }

        private void IssuePermits()
        {
            //buttonSave.Enabled = RoleFacade.PermissionUser(Main.userMenu[3], "");
        }

        private void buttonSearch_Click(object sender, EventArgs e)
        {
            string fullNamePatient = PatientManager.LoadDataPatient(textBoxSearchPatient.Text);
            textBoxFullNamePatient.Text = fullNamePatient;
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            //Agenda agenda = new Agenda();
            Appointment appointment = new Appointment();
            appointment.DateAppointment = Convert.ToString(monthCalendarAppointment.SelectionEnd.ToShortDateString());
                //monthCalendarAppointment.SelectionEnd;
            appointment.TimeAppointment = comboBoxTime.Text;
            //agenda.CIDoctor = "6600234";
            appointment.CIPatient = textBoxSearchPatient.Text;
            //agenda.TreatmentPatient = 1;
            appointment.StateAppointment = comboBoxState.Text;
            if (AgendaManager.NewAppointment(appointment))
            {
                MessageBox.Show("Successful registration");
            }
            else 
            {
                MessageBox.Show("The new Appointment could not be registered");
            }
        }
    }
}
